package com.example.qxfw.csnl.controller;

import com.example.qxfw.common.SysResult;
import com.example.qxfw.common.entity.zy.WaterLoggingPointInfo;
import com.example.qxfw.csnl.service.NldglService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@Slf4j
@ApiIgnore
@Api(tags = "城市内涝--内涝点管理")
@RestController
@CrossOrigin
@RequestMapping("/ManagementOfWaterloggingPointsController")
public class ManagementOfWaterloggingPointsController {
    @Autowired
    private NldglService nldglService;

    @ApiOperation("城市内涝--内涝点管理-增加")
    @RequestMapping("/insertOneData")
    public SysResult insertOneData(@RequestBody WaterLoggingPointInfo waterLoggingPointInfo){
        WaterLoggingPointInfo waterLoggingPointInfo1 = nldglService.insertOneData(waterLoggingPointInfo);
        if (waterLoggingPointInfo1!=null){
            return SysResult.success(waterLoggingPointInfo1);
        }else {
            return SysResult.fail("保存失败");
        }
    }

    @ApiOperation("城市内涝--内涝点管理-删除")
    @RequestMapping("/deleteById")
    public SysResult deleteById(int id){
        int result = nldglService.deleteById(id);
        return SysResult.common(result);
    }

    @ApiOperation("城市内涝--内涝点管理-修改")
    @RequestMapping("/updateById")
    public SysResult updateById(@RequestBody WaterLoggingPointInfo waterLoggingPointInfo){
        WaterLoggingPointInfo waterLoggingPointInfo1 = nldglService.updateById(waterLoggingPointInfo);
        if (waterLoggingPointInfo1!=null){
            return SysResult.success(waterLoggingPointInfo1);
        } else {
            return SysResult.fail("修改失败");
        }
    }

    @ApiOperation("城市内涝--内涝点管理-查询")
    @RequestMapping("/selectAllOfWaterLoggingPointInfo")
    public SysResult selectAllOfWaterLoggingPointInfo(){
        List<WaterLoggingPointInfo> list = nldglService.selectAllOfWaterLoggingPointInfo();
        return SysResult.common(list);
    }


}
